package com.spc.demo.business;

import java.util.ArrayList;
import java.util.List;

/**
 * 树节点
 */
public class Tree extends Component {
    List<Component> componentList = new ArrayList<>();

    private final String name;

    public Tree(String name) {
        this.name = name;
    }

    @Override
    public void add(Component component) {
        this.componentList.add(component);
    }

    @Override
    public void remove(Component component) {
        this.componentList.remove(component);
    }

    @Override
    public void print() {
        System.out.println("Tree name:" + this.name);
        for (Component component : componentList) {
            component.print();
        }
    }
}
